﻿

#region Using directives
using System;
using System.Web.UI.WebControls;
using InvoiceChecking.Data;
using InvoiceChecking.Entities;
using InvoiceChecking.Web.UI;

#endregion

public partial class Admin_ReceiveInvoice : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void btn_Add_Click(object sender, EventArgs e)
    {
        if (tb_InvoiceNumber.Text.Length==11)
        {
            string invoiceNumber = tb_InvoiceNumber.Text.Substring(0, 10);
            char version = tb_InvoiceNumber.Text[10];
            CheckInvoice checkInvoice = DataRepository.CheckInvoiceProvider.GetByVatInvoiceNumberCheckDate(invoiceNumber,DateTime.Now);
            if (checkInvoice==null)
                checkInvoice = new CheckInvoice{ VatInvoiceNumber = invoiceNumber};
            if (version == 'F')
                checkInvoice.FileCopy = true;
            else if (version=='C')
                checkInvoice.CustomerCopy = true;
            checkInvoice.CheckDate = DateTime.Now;
            DataRepository.CheckInvoiceProvider.Save(checkInvoice);
            GridView1.DataBind();
            tb_InvoiceNumber.Text = "";
        }
        tb_InvoiceNumber.Focus();
    }
    protected void btn_Print_Click(object sender, EventArgs e)
    {
        Response.Redirect("ReportReceive.aspx",true);
    }
}


